home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume14 / nntp1.5 / part03 < prev    next >
Encoding:
Internet Message Format  |  1988-04-18  |  56.5 KB

  1. Subject:  v14i049:  Network News Transfer Protocol, version 1.5, Part03/09
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Phil Lapsley <phil@ucbvax.berkeley.edu>
  7. Posting-number: Volume 14, Issue 49
  8. Archive-name: nntp1.5/part03
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 3 (of 9)."
  17. # Wrapped by rsalz@fig.bbn.com on Tue Apr 19 18:16:39 1988
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. if test -f './rrnpatches/Makefile.SH.pat' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'./rrnpatches/Makefile.SH.pat'\"
  21. else
  22. echo shar: Extracting \"'./rrnpatches/Makefile.SH.pat'\" \(4585 characters\)
  23. sed "s/^X//" >'./rrnpatches/Makefile.SH.pat' <<'END_OF_FILE'
  24. X*** rn/Makefile.SH    Sun Mar 15 19:54:40 1987
  25. X--- rrn/Makefile.SH    Thu Feb 25 20:38:38 1988
  26. X***************
  27. X*** 1,5
  28. X  case $CONFIG in
  29. X!     '') . config.sh ;;
  30. X  esac
  31. X  echo "Extracting Makefile (with variable substitutions)"
  32. X  cat >Makefile <<!GROK!THIS!
  33. X
  34. X--- 1,5 -----
  35. X  case $CONFIG in
  36. X!     '') . ./config.sh ;;
  37. X  esac
  38. X  echo "Extracting Makefile (with variable substitutions)"
  39. X  cat >Makefile <<!GROK!THIS!
  40. X***************
  41. X*** 21,26
  42. X  rnlib = $rnlib
  43. X  mansrc = $mansrc
  44. X  manext = $manext
  45. X  CFLAGS = $iandd -O
  46. X  LDFLAGS = $iandd
  47. X  NDIRC = $ndirc
  48. X
  49. X--- 21,27 -----
  50. X  rnlib = $rnlib
  51. X  mansrc = $mansrc
  52. X  manext = $manext
  53. X+ NNTPSRC = $NNTPSRC
  54. X  CFLAGS = $iandd -O
  55. X  LDFLAGS = $iandd
  56. X  NDIRC = $ndirc
  57. X***************
  58. X*** 31,37
  59. X  cat >>Makefile <<'!NO!SUBS!'
  60. X  
  61. X  public = rn newsetup newsgroups Pnews Rnmail
  62. X! private = norm.saver mbox.saver ng.help art.help pager.help subs.help makedir filexp Pnews.header
  63. X  manpages = rn.1 Pnews.1 Rnmail.1 newsetup.1 newsgroups.1
  64. X  util = Makefile makedepend newsnews
  65. X  
  66. X
  67. X--- 32,38 -----
  68. X  cat >>Makefile <<'!NO!SUBS!'
  69. X  
  70. X  public = rn newsetup newsgroups Pnews Rnmail
  71. X! private = norm.saver mbox.saver ng.help art.help pager.help subs.help makedir filexp Pnews.header getactive
  72. X  manpages = rn.1 Pnews.1 Rnmail.1 newsetup.1 newsgroups.1
  73. X  util = Makefile makedepend newsnews
  74. X  
  75. X***************
  76. X*** 45,51
  77. X  c1 = addng.c art.c artio.c artsrch.c backpage.c bits.c cheat.c
  78. X  c2 = final.c head.c help.c init.c intrp.c kfile.c last.c $(NDIRC) ng.c
  79. X  c3 = ngdata.c ngsrch.c ngstuff.c only.c rcln.c rcstuff.c
  80. X! c4 = respond.c rn.c search.c sw.c term.c util.c
  81. X  
  82. X  c = $(c1) $(c2) $(c3) $(c4)
  83. X  
  84. X
  85. X--- 46,52 -----
  86. X  c1 = addng.c art.c artio.c artsrch.c backpage.c bits.c cheat.c
  87. X  c2 = final.c head.c help.c init.c intrp.c kfile.c last.c $(NDIRC) ng.c
  88. X  c3 = ngdata.c ngsrch.c ngstuff.c only.c rcln.c rcstuff.c
  89. X! c4 = respond.c rn.c search.c sw.c term.c util.c $(NNTPSRC)/common/clientlib.c
  90. X  
  91. X  c = $(c1) $(c2) $(c3) $(c4)
  92. X  
  93. X***************
  94. X*** 52,58
  95. X  obj1 = addng.o art.o artio.o artsrch.o backpage.o bits.o cheat.o
  96. X  obj2 = final.o head.o help.o init.o intrp.o kfile.o last.o $(NDIRO) ng.o
  97. X  obj3 = ngdata.o ngsrch.o ngstuff.o only.o rcln.o rcstuff.o
  98. X! obj4 = respond.o rn.o search.o sw.o term.o util.o
  99. X  
  100. X  obj = $(obj1) $(obj2) $(obj3) $(obj4)
  101. X  
  102. X
  103. X--- 53,59 -----
  104. X  obj1 = addng.o art.o artio.o artsrch.o backpage.o bits.o cheat.o
  105. X  obj2 = final.o head.o help.o init.o intrp.o kfile.o last.o $(NDIRO) ng.o
  106. X  obj3 = ngdata.o ngsrch.o ngstuff.o only.o rcln.o rcstuff.o
  107. X! obj4 = respond.o rn.o search.o sw.o term.o util.o $(NNTPSRC)/common/clientlib.o
  108. X  
  109. X  obj = $(obj1) $(obj2) $(obj3) $(obj4)
  110. X  
  111. X***************
  112. X*** 78,83
  113. X  rn: $(obj)
  114. X      $(CC) $(LDFLAGS) $(obj) $(libs) -o rn
  115. X  
  116. X  # if a .h file depends on another .h file...
  117. X  $(h):
  118. X      touch $@
  119. X
  120. X--- 79,92 -----
  121. X  rn: $(obj)
  122. X      $(CC) $(LDFLAGS) $(obj) $(libs) -o rn
  123. X  
  124. X+ getactive: getactive.o $(NNTPSRC)/common/clientlib.o
  125. X+     $(CC) $(LDFLAGS) getactive.o $(NNTPSRC)/common/clientlib.o -o getactive
  126. X+ 
  127. X+ # Eek! This is gross.
  128. X+ $(NNTPSRC)/common/clientlib.o:
  129. X+     $(CC) -c $(CFLAGS) $(NNTPSRC)/common/clientlib.c
  130. X+     mv clientlib.o $(NNTPSRC)/common/clientlib.o
  131. X+ 
  132. X  # if a .h file depends on another .h file...
  133. X  $(h):
  134. X      touch $@
  135. X***************
  136. X*** 86,91
  137. X  # won't work with csh
  138. X      export PATH || exit 1
  139. X      - mv $(rnbin)/rn $(rnbin)/rn.old
  140. X      - if test `pwd` != $(rnbin); then cp $(public) $(rnbin); fi
  141. X      cd $(rnbin); chmod 755 $(public)
  142. X      chmod 755 makedir
  143. X
  144. X--- 95,101 -----
  145. X  # won't work with csh
  146. X      export PATH || exit 1
  147. X      - mv $(rnbin)/rn $(rnbin)/rn.old
  148. X+     - ln -s $(rnbin)/rn $(rnbin)/rrn
  149. X      - if test `pwd` != $(rnbin); then cp $(public) $(rnbin); fi
  150. X      cd $(rnbin); chmod 755 $(public)
  151. X      chmod 755 makedir
  152. X***************
  153. X*** 103,109
  154. X      rm -f *.o
  155. X  
  156. X  realclean:
  157. X!     rm -f rn *.o core $(addedbyconf)
  158. X  
  159. X  # The following lint has practically everything turned on.  Unfortunately,
  160. X  # you have to wade through a lot of mumbo jumbo that can't be suppressed.
  161. X
  162. X--- 113,119 -----
  163. X      rm -f *.o
  164. X  
  165. X  realclean:
  166. X!     rm -f rn *.o core $(addedbyconf) $(NNTPSRC)/common/clientlib.o
  167. X  
  168. X  # The following lint has practically everything turned on.  Unfortunately,
  169. X  # you have to wade through a lot of mumbo jumbo that can't be suppressed.
  170. X***************
  171. X*** 114,120
  172. X      lint $(lintflags) $(defs) $(c) > rn.fuzz
  173. X  
  174. X  depend:
  175. X!     makedepend
  176. X  
  177. X  # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
  178. X  $(obj):
  179. X
  180. X--- 124,130 -----
  181. X      lint $(lintflags) $(defs) $(c) > rn.fuzz
  182. X  
  183. X  depend:
  184. X!     ./makedepend
  185. X  
  186. X  # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
  187. X  $(obj):
  188. END_OF_FILE
  189. if test 4585 -ne `wc -c <'./rrnpatches/Makefile.SH.pat'`; then
  190.     echo shar: \"'./rrnpatches/Makefile.SH.pat'\" unpacked with wrong size!
  191. fi
  192. # end of './rrnpatches/Makefile.SH.pat'
  193. fi
  194. if test -f './rrnpatches/artio.c.pat' -a "${1}" != "-c" ; then 
  195.   echo shar: Will not clobber existing file \"'./rrnpatches/artio.c.pat'\"
  196. else
  197. echo shar: Extracting \"'./rrnpatches/artio.c.pat'\" \(3894 characters\)
  198. sed "s/^X//" >'./rrnpatches/artio.c.pat' <<'END_OF_FILE'
  199. X*** rn/artio.c    Sun Mar 15 19:54:46 1987
  200. X--- rrn/artio.c    Wed Aug 19 21:29:20 1987
  201. X***************
  202. X*** 8,13
  203. X  
  204. X  #include "EXTERN.h"
  205. X  #include "common.h"
  206. X  #include "INTERN.h"
  207. X  #include "artio.h"
  208. X  
  209. X
  210. X--- 8,14 -----
  211. X  
  212. X  #include "EXTERN.h"
  213. X  #include "common.h"
  214. X+ #include "server.h"
  215. X  #include "INTERN.h"
  216. X  #include "artio.h"
  217. X  
  218. X***************
  219. X*** 23,29
  220. X  artopen(artnum)
  221. X  ART_NUM artnum;
  222. X  {
  223. X!     char artname[8];            /* filename of current article */
  224. X  
  225. X      if (artnum < 1)
  226. X      return Nullfp;
  227. X
  228. X--- 24,34 -----
  229. X  artopen(artnum)
  230. X  ART_NUM artnum;
  231. X  {
  232. X! #ifdef SERVER
  233. X!     static long our_pid;
  234. X!     char ser_line[256];
  235. X! #endif SERVER
  236. X!     char artname[32];            /* filename of current article */
  237. X  
  238. X  #ifdef SERVER
  239. X      if (our_pid == 0)
  240. X***************
  241. X*** 25,30
  242. X  {
  243. X      char artname[8];            /* filename of current article */
  244. X  
  245. X      if (artnum < 1)
  246. X      return Nullfp;
  247. X      if (openart == artnum) {        /* this article is already open? */
  248. X
  249. X--- 30,40 -----
  250. X  #endif SERVER
  251. X      char artname[32];            /* filename of current article */
  252. X  
  253. X+ #ifdef SERVER
  254. X+     if (our_pid == 0)
  255. X+     our_pid = getpid();
  256. X+ #endif SERVER
  257. X+ 
  258. X      if (artnum < 1)
  259. X      return Nullfp;
  260. X      if (openart == artnum) {        /* this article is already open? */
  261. X***************
  262. X*** 33,38
  263. X      }
  264. X      if (artfp != Nullfp) {        /* it was somebody else? */
  265. X      fclose(artfp);            /* put them out of their misery */
  266. X      openart = 0;            /* and remember them no more */
  267. X      }
  268. X      sprintf(artname,"%ld",(long)artnum);
  269. X
  270. X--- 43,52 -----
  271. X      }
  272. X      if (artfp != Nullfp) {        /* it was somebody else? */
  273. X      fclose(artfp);            /* put them out of their misery */
  274. X+ #ifdef SERVER
  275. X+     sprintf(artname, "/tmp/rrn%ld.%ld", (long) openart, our_pid);
  276. X+     UNLINK(artname);
  277. X+ #endif SERVER
  278. X      openart = 0;            /* and remember them no more */
  279. X      }
  280. X  
  281. X***************
  282. X*** 35,40
  283. X      fclose(artfp);            /* put them out of their misery */
  284. X      openart = 0;            /* and remember them no more */
  285. X      }
  286. X      sprintf(artname,"%ld",(long)artnum);
  287. X                      /* produce the name of the article */
  288. X      if (artfp = fopen(artname,"r"))    /* if we can open it */
  289. X
  290. X--- 49,92 -----
  291. X  #endif SERVER
  292. X      openart = 0;            /* and remember them no more */
  293. X      }
  294. X+ 
  295. X+ #ifdef SERVER
  296. X+ 
  297. X+     sprintf(artname,"/tmp/rrn%ld.%ld", (long) artnum, our_pid);
  298. X+     artfp = fopen(artname, "w+");    /* create the temporary article */
  299. X+     if (artfp == Nullfp) {
  300. X+     UNLINK(artname);
  301. X+     return Nullfp;
  302. X+     }
  303. X+     sprintf(ser_line, "ARTICLE %ld", (long)artnum);
  304. X+     put_server(ser_line);        /* ask the server for the article */
  305. X+     if (get_server(ser_line, sizeof(ser_line)) < 0) {
  306. X+     fprintf(stderr, "rrn: Unexpected close of server socket.\n");
  307. X+     finalize(1);
  308. X+     }
  309. X+     if (*ser_line != CHAR_OK) {        /* and get it's reaction */
  310. X+     fclose(artfp);
  311. X+     artfp = Nullfp;
  312. X+     UNLINK(artname);
  313. X+         return Nullfp;
  314. X+     }
  315. X+ 
  316. X+     for (;;) {
  317. X+         if (get_server(ser_line, sizeof(ser_line)) < 0) {
  318. X+         fprintf(stderr, "rrn: Unexpected close of server socket.\n");
  319. X+         finalize(1);
  320. X+     }
  321. X+     if (ser_line[0] == '.' && ser_line[1] == '\0')
  322. X+         break;
  323. X+     fputs((ser_line[0] == '.' ? ser_line + 1 : ser_line), artfp);
  324. X+     putc('\n', artfp);
  325. X+     }
  326. X+ 
  327. X+     fseek(artfp, 0L, 0);        /* Then get back to the start */
  328. X+     openart = artnum;
  329. X+ 
  330. X+ #else not SERVER
  331. X+ 
  332. X      sprintf(artname,"%ld",(long)artnum);
  333. X                      /* produce the name of the article */
  334. X      if (artfp = fopen(artname,"r"))    /* if we can open it */
  335. X***************
  336. X*** 39,44
  337. X                      /* produce the name of the article */
  338. X      if (artfp = fopen(artname,"r"))    /* if we can open it */
  339. X      openart = artnum;        /* remember what we did here */
  340. X  #ifdef LINKART
  341. X      {
  342. X      char tmpbuf[256];
  343. X
  344. X--- 91,98 -----
  345. X                      /* produce the name of the article */
  346. X      if (artfp = fopen(artname,"r"))    /* if we can open it */
  347. X      openart = artnum;        /* remember what we did here */
  348. X+ 
  349. X+ #endif SERVER
  350. X  #ifdef LINKART
  351. X      {
  352. X      char tmpbuf[256];
  353. END_OF_FILE
  354. if test 3894 -ne `wc -c <'./rrnpatches/artio.c.pat'`; then
  355.     echo shar: \"'./rrnpatches/artio.c.pat'\" unpacked with wrong size!
  356. fi
  357. # end of './rrnpatches/artio.c.pat'
  358. fi
  359. if test -f './rrnpatches/common.h.pat' -a "${1}" != "-c" ; then 
  360.   echo shar: Will not clobber existing file \"'./rrnpatches/common.h.pat'\"
  361. else
  362. echo shar: Extracting \"'./rrnpatches/common.h.pat'\" \(4168 characters\)
  363. sed "s/^X//" >'./rrnpatches/common.h.pat' <<'END_OF_FILE'
  364. X*** rn/common.h    Sun Mar 15 19:54:22 1987
  365. X--- rrn/common.h    Sun Mar 15 22:20:24 1987
  366. X***************
  367. X*** 567,573
  368. X  
  369. X  #ifndef PIPESAVER        /* % */
  370. X  #   ifdef CONDSUB
  371. X! #    define PIPESAVER "%(%B=^0$?<%A:tail +%Bc %A |) %b"
  372. X  #   else
  373. X  #    define PIPESAVER "tail +%Bc %A | %b"
  374. X  #   endif
  375. X
  376. X--- 567,577 -----
  377. X  
  378. X  #ifndef PIPESAVER        /* % */
  379. X  #   ifdef CONDSUB
  380. X! #       ifdef SERVER
  381. X! #               define PIPESAVER "%(%B=^0$?<%P/rrn%a.%$:tail +%Bc %P/rrn%a.%$ |) %b"
  382. X! #       else
  383. X! #        define PIPESAVER "%(%B=^0$?<%A:tail +%Bc %A |) %b"
  384. X! #    endif
  385. X  #   else
  386. X  #       ifdef SERVER
  387. X  #               define PIPESAVER "tail +%Bc %P/rrn%a.%$ | %b"
  388. X***************
  389. X*** 569,575
  390. X  #   ifdef CONDSUB
  391. X  #    define PIPESAVER "%(%B=^0$?<%A:tail +%Bc %A |) %b"
  392. X  #   else
  393. X! #    define PIPESAVER "tail +%Bc %A | %b"
  394. X  #   endif
  395. X  #endif
  396. X  
  397. X
  398. X--- 573,583 -----
  399. X  #        define PIPESAVER "%(%B=^0$?<%A:tail +%Bc %A |) %b"
  400. X  #    endif
  401. X  #   else
  402. X! #       ifdef SERVER
  403. X! #               define PIPESAVER "tail +%Bc %P/rrn%a.%$ | %b"
  404. X! #       else
  405. X! #        define PIPESAVER "tail +%Bc %A | %b"
  406. X! #    endif
  407. X  #   endif
  408. X  #endif
  409. X  
  410. X***************
  411. X*** 574,580
  412. X  #endif
  413. X  
  414. X  #ifndef NORMSAVER        /* % and ~ */
  415. X! #   define NORMSAVER "%X/norm.saver %A %P %c %a %B %C \"%b\""
  416. X  #endif
  417. X  
  418. X  #ifndef MBOXSAVER        /* % and ~ */
  419. X
  420. X--- 582,592 -----
  421. X  #endif
  422. X  
  423. X  #ifndef NORMSAVER        /* % and ~ */
  424. X! #    ifdef SERVER
  425. X! #    define NORMSAVER "%X/norm.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\""
  426. X! #    else
  427. X! #       define NORMSAVER "%X/norm.saver %A %P %c %a %B %C \"%b\""
  428. X! #    endif
  429. X  #endif
  430. X  
  431. X  #ifndef MBOXSAVER        /* % and ~ */
  432. X***************
  433. X*** 579,585
  434. X  
  435. X  #ifndef MBOXSAVER        /* % and ~ */
  436. X  #   ifdef MININACT        /* 2.10.2 site? */
  437. X! #    define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %`date`\""
  438. X  #   else
  439. X  #    ifdef CONDSUB
  440. X  #        define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %(%[date]=^\\(\\w*\\), \\(\\w*\\)-\\(\\w*\\)-\\(\\w*\\) \\([^ ]*\\)?%1 %3 %(%2=..?%2: %2) %5 19%4)\""
  441. X
  442. X--- 591,601 -----
  443. X  
  444. X  #ifndef MBOXSAVER        /* % and ~ */
  445. X  #   ifdef MININACT        /* 2.10.2 site? */
  446. X! #       ifdef SERVER
  447. X! #           define MBOXSAVER "%X/mbox.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\" \"From %T %`date`\""
  448. X! #       else
  449. X! #        define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %`date`\""
  450. X! #    endif SERVER
  451. X  #   else
  452. X  #    ifdef CONDSUB
  453. X  #           ifdef SERVER
  454. X***************
  455. X*** 582,588
  456. X  #    define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %`date`\""
  457. X  #   else
  458. X  #    ifdef CONDSUB
  459. X! #        define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %(%[date]=^\\(\\w*\\), \\(\\w*\\)-\\(\\w*\\)-\\(\\w*\\) \\([^ ]*\\)?%1 %3 %(%2=..?%2: %2) %5 19%4)\""
  460. X                      /* header munging with a vengeance */
  461. X  #    else
  462. X  #        define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %[posted]\""
  463. X
  464. X--- 598,610 -----
  465. X  #    endif SERVER
  466. X  #   else
  467. X  #    ifdef CONDSUB
  468. X! #           ifdef SERVER
  469. X! #               define MBOXSAVER "%X/mbox.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\
  470. X! " \"From %T %(%[date]=^\\(\\w*\\), \\(\\w*\\)-\\(\\w*\\)-\\(\\w*\\) \\([^ ]*\\)?
  471. X! %1 %3 %(%2=..?%2: %2) %5 19%4)\""
  472. X! #           else
  473. X! #            define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %(%[date]=^\\(\\w*\\), \\(\\w*\\)-\\(\\w*\\)-\\(\\w*\\) \\([^ ]*\\)?%1 %3 %(%2=..?%2: %2) %5 19%4)\""
  474. X! #        endif
  475. X                      /* header munging with a vengeance */
  476. X  #    else
  477. X  #           ifdef SERVER
  478. X***************
  479. X*** 585,591
  480. X  #        define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %(%[date]=^\\(\\w*\\), \\(\\w*\\)-\\(\\w*\\)-\\(\\w*\\) \\([^ ]*\\)?%1 %3 %(%2=..?%2: %2) %5 19%4)\""
  481. X                      /* header munging with a vengeance */
  482. X  #    else
  483. X! #        define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %[posted]\""
  484. X  #    endif
  485. X  #   endif
  486. X  #endif
  487. X
  488. X--- 607,617 -----
  489. X  #        endif
  490. X                      /* header munging with a vengeance */
  491. X  #    else
  492. X! #           ifdef SERVER
  493. X! #               define MBOXSAVER "%X/mbox.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\" \"From %T %[posted]\""
  494. X! #           else
  495. X! #            define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %[posted]\""
  496. X! #        endif
  497. X  #    endif
  498. X  #   endif
  499. X  #endif
  500. END_OF_FILE
  501. if test 4168 -ne `wc -c <'./rrnpatches/common.h.pat'`; then
  502.     echo shar: \"'./rrnpatches/common.h.pat'\" unpacked with wrong size!
  503. fi
  504. # end of './rrnpatches/common.h.pat'
  505. fi
  506. if test -f './rrnpatches/head.c.pat' -a "${1}" != "-c" ; then 
  507.   echo shar: Will not clobber existing file \"'./rrnpatches/head.c.pat'\"
  508. else
  509. echo shar: Extracting \"'./rrnpatches/head.c.pat'\" \(3320 characters\)
  510. sed "s/^X//" >'./rrnpatches/head.c.pat' <<'END_OF_FILE'
  511. X*** rn/head.c    Sun Mar 15 19:54:37 1987
  512. X--- rrn/head.c    Mon Jun  1 10:18:35 1987
  513. X***************
  514. X*** 16,21
  515. X  #include "common.h"
  516. X  #include "artio.h"
  517. X  #include "bits.h"
  518. X  #include "util.h"
  519. X  #include "INTERN.h"
  520. X  #include "head.h"
  521. X
  522. X--- 16,22 -----
  523. X  #include "common.h"
  524. X  #include "artio.h"
  525. X  #include "bits.h"
  526. X+ #include "server.h"
  527. X  #include "util.h"
  528. X  #include "INTERN.h"
  529. X  #include "head.h"
  530. X***************
  531. X*** 180,185
  532. X  bool copy;                /* do you want it savestr()ed? */
  533. X  {
  534. X      char *s = Nullch, *t;
  535. X  
  536. X  #ifdef CACHESUBJ
  537. X      if (!subj_list) {
  538. X
  539. X--- 181,191 -----
  540. X  bool copy;                /* do you want it savestr()ed? */
  541. X  {
  542. X      char *s = Nullch, *t;
  543. X+ #ifdef SERVER
  544. X+     static int xhdr = 1;        /* Can we use xhdr command? */
  545. X+     int eoo;                /* End of server output */
  546. X+     char ser_line[256];
  547. X+ #endif SERVER
  548. X  
  549. X  #ifdef CACHESUBJ
  550. X      if (!subj_list) {
  551. X***************
  552. X*** 208,213
  553. X      else {
  554. X          s = safemalloc((MEM_SIZE)256);
  555. X          *s = '\0';
  556. X          if (artopen(artnum) != Nullfp) {
  557. X          do {
  558. X              if (fgets(s,256,artfp) == Nullch)
  559. X
  560. X--- 214,268 -----
  561. X      else {
  562. X          s = safemalloc((MEM_SIZE)256);
  563. X          *s = '\0';
  564. X+ #ifdef SERVER
  565. X+         if (xhdr) {
  566. X+             sprintf(ser_line, "XHDR subject %ld", artnum);
  567. X+             put_server(ser_line);
  568. X+         if (get_server(ser_line, sizeof (ser_line)) >= 0) {
  569. X+             if (ser_line[0] == CHAR_FATAL) {
  570. X+                 xhdr = 0;
  571. X+             } else {
  572. X+                 while (get_server(ser_line, sizeof (ser_line)) >= 0) {
  573. X+                 if (ser_line[0] == '.')
  574. X+                     break;
  575. X+                 else {
  576. X+                     t = index(ser_line, ' ');
  577. X+                     if (t++) {
  578. X+                     strcpy(s, t);
  579. X+                     if (t = index(s, '\r'))
  580. X+                         *t = '\0';
  581. X+                     }
  582. X+                 }
  583. X+                 }
  584. X+             }
  585. X+         } else {
  586. X+             fprintf(stderr,
  587. X+             "rrn: Unexpected close of server socket.\n");
  588. X+             finalize(1);
  589. X+         }
  590. X+         }
  591. X+ 
  592. X+         if (!xhdr) {
  593. X+         sprintf(ser_line, "HEAD %ld", artnum);
  594. X+         put_server(ser_line);
  595. X+         eoo = 0;
  596. X+         if (get_server(ser_line, 256) >= 0 && ser_line[0] == CHAR_OK) {
  597. X+             do {
  598. X+             if (get_server(s, 256) < 0 || (*s == '.')) {
  599. X+             strcpy(s, "Title: \n");
  600. X+             eoo = 1;
  601. X+                 }
  602. X+             } while (strnNE(s,"Title:",6) && strnNE(s,"Subject:",8));
  603. X+ 
  604. X+             if (!eoo)
  605. X+             while (get_server(ser_line, sizeof (ser_line)) >= 0 &&
  606. X+                 ser_line[0] != '.');
  607. X+             t = index(s,':')+1;
  608. X+             while (*t == ' ') t++;
  609. X+             strcpy(s, t);
  610. X+             }
  611. X+         }
  612. X+ #else not SERVER
  613. X          if (artopen(artnum) != Nullfp) {
  614. X          do {
  615. X              if (fgets(s,256,artfp) == Nullch)
  616. X***************
  617. X*** 213,218
  618. X              if (fgets(s,256,artfp) == Nullch)
  619. X              strcpy(s, "Title: \n");
  620. X          } while (strnNE(s,"Title:",6) && strnNE(s,"Subject:",8));
  621. X          s[strlen(s)-1] = '\0';
  622. X          t = index(s,':')+1;
  623. X          while (*t == ' ') t++;
  624. X
  625. X--- 268,274 -----
  626. X              if (fgets(s,256,artfp) == Nullch)
  627. X              strcpy(s, "Title: \n");
  628. X          } while (strnNE(s,"Title:",6) && strnNE(s,"Subject:",8));
  629. X+ 
  630. X          s[strlen(s)-1] = '\0';
  631. X          t = index(s,':')+1;
  632. X          while (*t == ' ') t++;
  633. X***************
  634. X*** 218,223
  635. X          while (*t == ' ') t++;
  636. X          strcpy(s, t);
  637. X          }
  638. X          s = saferealloc(s, (MEM_SIZE)strlen(s)+1);
  639. X  #ifdef CACHESUBJ
  640. X          subj_list[OFFSET(artnum)] = s;
  641. X
  642. X--- 274,280 -----
  643. X          while (*t == ' ') t++;
  644. X          strcpy(s, t);
  645. X          }
  646. X+ #endif
  647. X          s = saferealloc(s, (MEM_SIZE)strlen(s)+1);
  648. X  #ifdef CACHESUBJ
  649. X          subj_list[OFFSET(artnum)] = s;
  650. END_OF_FILE
  651. if test 3320 -ne `wc -c <'./rrnpatches/head.c.pat'`; then
  652.     echo shar: \"'./rrnpatches/head.c.pat'\" unpacked with wrong size!
  653. fi
  654. # end of './rrnpatches/head.c.pat'
  655. fi
  656. if test -f './server/README' -a "${1}" != "-c" ; then 
  657.   echo shar: Will not clobber existing file \"'./server/README'\"
  658. else
  659. echo shar: Extracting \"'./server/README'\" \(2963 characters\)
  660. sed "s/^X//" >'./server/README' <<'END_OF_FILE'
  661. X     Caveat: Before compiling anything here, go look at README and conf.h
  662. in the "common" directory.  Fix conf.h up, and then come back here.
  663. X
  664. X     Back already?  Ok.  Now following the bouncing numbers:
  665. X
  666. X    1. Create the access file with the proper entries.
  667. X       This file goes wherever you said ACCESS_FILE
  668. X       was supposed to be in common/conf.h.  It's format is
  669. X       explained in the manual entry for nntpd.8c.
  670. X       A sample access file is in ../support/access_file.
  671. X       If you don't care who (ab)uses your news server,
  672. X       you can have the line "default read post" in your access
  673. X       file, which will allow anyone on the network to
  674. X       read and post news via your server.  See the manual
  675. X       page for a better explanation.
  676. X
  677. Parts two and three are necessary if you're running with TCP:
  678. X
  679. X    2. Make an entry for "nntp" in /etc/services.  Should
  680. X       be port number 119, tcp.  I.e., should look something like:
  681. X
  682. nntp        119/tcp        readnews    # Network News Transfer Protocol
  683. X
  684. X       Sun users running yp should yppush this file to make sure all
  685. X       the clients get it.
  686. X
  687. X    3. Check ../common/conf.h to make sure you're set to do what
  688. X       you want to do with inetd (i.e., #define ALONE or #undef ALONE).
  689. X       If you are using inetd,
  690. X
  691. X       a. Add a line to /etc/inetd.conf, or whatever your
  692. X          configuration file is, to reflect the presence
  693. X          of the news server.  On 4.3 BSD machines this should
  694. X          look like:
  695. X
  696. nntp    stream    tcp    nowait    root    /etc/nntpd    nntpd
  697. X
  698. X          while under Ultrix or 4.2 BSD machines:
  699. X
  700. nntp    stream    tcp    nowait    /etc/nntpd    nntpd
  701. X
  702. X          On a Sun, the file is /etc/servers; the line looks like:
  703. X
  704. nntp    tcp    /usr/etc/in.nntpd
  705. X
  706. X          Be sure to yppush your /etc/servers file if you run
  707. X          yellow pages.
  708. X
  709. X          Don't forget to kill -HUP your inetd.
  710. X
  711. X       If you're NOT using inetd,
  712. X
  713. X       a. Edit ../common/conf.h to have the line
  714. X
  715. X            #define ALONE
  716. X
  717. X          to compile in code for the stand alone server.
  718. X
  719. X       b. You may as well also define "FASTFORK" in
  720. X          ../common/conf.h.  This causes the server not to
  721. X          read in the active file every time it forks, but
  722. X          rather to stat it every READINTVL seconds, and if
  723. X          the file has changed since the last read, to
  724. X          read it in again.  This makes the children run
  725. X          faster, since they don't have to read the active
  726. X          file every time the parent forks off a child, but
  727. X          the parent server will eat more cpu, doing
  728. X          stat()s every 10 minutes or so.  If your server machine
  729. X          is heavily loaded, you might leave this out.
  730. X
  731. X       c. Change /etc/rc.local to start the server at
  732. X          boot time.
  733. X
  734. Else, if you're using decnet:
  735. X
  736. X    2. && 3. Define the NNTP object with ncp:
  737. X
  738. ncp define object NNTP number 0 file /etc/nntpd
  739. ncp define object NNTP default user guest type stream
  740. X
  741. ncp set object NNTP all            # just once for the running system
  742. X
  743. X    4. Compile the server by doing "make".
  744. X
  745. X    5. Cd .. and continue with the rest of the stuff; you'll
  746. X       wind up doing a make install later.
  747. END_OF_FILE
  748. if test 2963 -ne `wc -c <'./server/README'`; then
  749.     echo shar: \"'./server/README'\" unpacked with wrong size!
  750. fi
  751. # end of './server/README'
  752. fi
  753. if test -f './server/access.c' -a "${1}" != "-c" ; then 
  754.   echo shar: Will not clobber existing file \"'./server/access.c'\"
  755. else
  756. echo shar: Extracting \"'./server/access.c'\" \(4680 characters\)
  757. sed "s/^X//" >'./server/access.c' <<'END_OF_FILE'
  758. X#ifndef lint
  759. static char    *sccsid = "@(#)access.c    1.19    (Berkeley) 2/6/88";
  760. X#endif
  761. X
  762. X#include "common.h"
  763. X#ifdef EXCELAN
  764. X#include <netinet/in.h>
  765. X#endif
  766. X#include <sys/socket.h>
  767. X
  768. X#define    SNETMATCH    1
  769. X#define    NETMATCH    2
  770. X
  771. X/*
  772. X * host_access -- determine if the client has permission to
  773. X * read, transfer, and/or post news.  read->transfer.
  774. X * We switch on socket family so as to isolate network dependent code.
  775. X *
  776. X *    Parameters:    "canread" is a pointer to storage for
  777. X *            an integer, which we set to 1 if the
  778. X *            client can read news, 0 otherwise.
  779. X *
  780. X *            "canpost" is a pointer to storage for
  781. X *            an integer,which we set to 1 if the
  782. X *            client can post news, 0 otherwise.
  783. X *
  784. X *            "canxfer" is a pointer to storage for
  785. X *            an integer,which we set to 1 if the
  786. X *            client can transfer news, 0 otherwise.
  787. X *
  788. X *            "gdlist" is a comma separated list of
  789. X *            newsgroups/distributions which the client
  790. X *            can access.
  791. X *
  792. X *    Returns:    Nothing.
  793. X *
  794. X *    Side effects:    None.
  795. X */
  796. X
  797. X#ifdef EXCELAN
  798. extern struct sockaddr_in current_peer;
  799. X#endif
  800. X
  801. X#ifdef LOG
  802. char    hostname[256];
  803. X#endif
  804. X
  805. host_access(canread, canpost, canxfer, gdlist)
  806. X    int        *canread, *canpost, *canxfer;
  807. X    char        *gdlist;
  808. X{
  809. X    int        sockt;
  810. X    int        length;
  811. X    struct sockaddr    sa;
  812. X    int        match;
  813. X    int        count;
  814. X    char        hostornet[MAXHOSTNAMELEN];
  815. X    char        host_name[MAXHOSTNAMELEN];
  816. X    char        net_name[MAXHOSTNAMELEN];
  817. X    char        snet_name[MAXHOSTNAMELEN];
  818. X    char        readperm[MAXBUFLEN];
  819. X    char        postperm[MAXBUFLEN];
  820. X    char        groups[MAXBUFLEN];
  821. X    char        line[MAXBUFLEN];
  822. X    register char    *cp;
  823. X    register FILE    *acs_fp;
  824. X
  825. X    gdlist[0] = '\0';
  826. X
  827. X#ifdef DEBUG
  828. X    *canread = *canpost = *canxfer = 1;
  829. X    return;
  830. X#endif
  831. X
  832. X    *canread = *canpost = *canxfer = 0;
  833. X
  834. X    sockt = fileno(stdin);
  835. X    length = sizeof (sa);
  836. X
  837. X#ifdef EXCELAN
  838. X    if (raddr(current_peer.sin_addr) == NULL) {
  839. X#else
  840. X    if (getpeername(sockt, &sa, &length) < 0) {
  841. X#endif
  842. X        if (isatty(sockt)) {
  843. X#ifdef LOG
  844. X            (void) strcpy(hostname, "stdin");
  845. X#endif
  846. X            *canread = 1;
  847. X        } else {
  848. X#ifdef SYSLOG
  849. X            syslog(LOG_ERR, "host_access: getpeername: %m");
  850. X#endif
  851. X#ifdef LOG
  852. X            (void) strcpy(hostname, "unknown");
  853. X#endif
  854. X        }
  855. X        return;
  856. X    }
  857. X#ifdef EXCELAN
  858. X    else bcopy(¤t_peer,&sa,length);
  859. X#endif
  860. X
  861. X    switch (sa.sa_family) {
  862. X    case AF_INET:
  863. X        inet_netnames(sockt, &sa, net_name, snet_name, host_name);
  864. X        break;
  865. X
  866. X#ifdef DECNET
  867. X    case AF_DECnet:
  868. X        dnet_netnames(sockt, &sa, net_name, snet_name, host_name);
  869. X        break;
  870. X#endif
  871. X
  872. X    default:
  873. X#ifdef SYSLOG
  874. X        syslog(LOG_ERR, "unknown address family %ld", sa.sa_family);
  875. X#endif
  876. X        return;
  877. X    };
  878. X
  879. X    /* Normalize host name to lower case */
  880. X
  881. X    for (cp = host_name; *cp; cp++)
  882. X        if (isupper(*cp))
  883. X            *cp = tolower(*cp);
  884. X
  885. X#ifdef LOG
  886. X    syslog(LOG_INFO, "%s connect\n", host_name);
  887. X    (void) strcpy(hostname, host_name);
  888. X#endif
  889. X
  890. X    /*
  891. X     * We now we have host_name, snet_name, and net_name.
  892. X     * Our strategy at this point is:
  893. X     *
  894. X     * for each line, get the first word
  895. X     *
  896. X     *    If it matches "host_name", we have a direct
  897. X     *        match; parse and return.
  898. X     *
  899. X     *    If it matches "snet_name", we have a subnet match;
  900. X     *        parse and set flags.
  901. X     *
  902. X     *    If it matches "net_name", we have a net match;
  903. X     *        parse and set flags.
  904. X     *
  905. X     *    If it matches the literal "default", note we have
  906. X     *        a net match; parse.
  907. X     */
  908. X
  909. X    acs_fp = fopen(accessfile, "r");
  910. X    if (acs_fp == NULL) {
  911. X#ifdef SYSLOG
  912. X        syslog(LOG_ERR, "access: fopen %s: %m", accessfile);
  913. X#endif
  914. X        return;
  915. X    }
  916. X
  917. X    while (fgets(line, sizeof(line), acs_fp) != NULL) {
  918. X        if ((cp = index(line, '\n')) != NULL)
  919. X            *cp = '\0';
  920. X        if ((cp = index(line, '#')) != NULL)
  921. X            *cp = '\0';
  922. X        if (*line == '\0')
  923. X            continue;
  924. X
  925. X        count = sscanf(line, "%s %s %s %s",
  926. X                hostornet, readperm, postperm, groups);
  927. X
  928. X        if (count < 4) {
  929. X            if (count < 3)
  930. X                continue;
  931. X            groups[0] = '\0';    /* No groups specified */
  932. X        }
  933. X
  934. X        if (!strcasecmp(hostornet, host_name)) {
  935. X            *canread = (readperm[0] == 'r' || readperm[0] == 'R');
  936. X            *canxfer = (*canread || readperm[0] == 'X'
  937. X                         || readperm[0] == 'x');
  938. X            *canpost = (postperm[0] == 'p' || postperm[0] == 'P');
  939. X            (void) strcpy(gdlist, groups);
  940. X            break;
  941. X        }
  942. X
  943. X        if (*snet_name && !strcasecmp(hostornet, snet_name)) {
  944. X            match = SNETMATCH;
  945. X            *canread = (readperm[0] == 'r' || readperm[0] == 'R');
  946. X            *canxfer = (*canread || readperm[0] == 'X'
  947. X                         || readperm[0] == 'x');
  948. X            *canpost = (postperm[0] == 'p' || postperm[0] == 'P');
  949. X            (void) strcpy(gdlist, groups);
  950. X        }
  951. X
  952. X        if (match != SNETMATCH && (!strcasecmp(hostornet, net_name) ||
  953. X            !strcasecmp(hostornet, "default"))) {
  954. X            match = NETMATCH;
  955. X            *canread = (readperm[0] == 'r' || readperm[0] == 'R');
  956. X            *canxfer = (*canread || readperm[0] == 'X'
  957. X                         || readperm[0] == 'x');
  958. X            *canpost = (postperm[0] == 'p' || postperm[0] == 'P');
  959. X            (void) strcpy(gdlist, groups);
  960. X        }
  961. X    }
  962. X
  963. X    (void) fclose(acs_fp);
  964. X}
  965. END_OF_FILE
  966. if test 4680 -ne `wc -c <'./server/access.c'`; then
  967.     echo shar: \"'./server/access.c'\" unpacked with wrong size!
  968. fi
  969. # end of './server/access.c'
  970. fi
  971. if test -f './server/access_inet.c' -a "${1}" != "-c" ; then 
  972.   echo shar: Will not clobber existing file \"'./server/access_inet.c'\"
  973. else
  974. echo shar: Extracting \"'./server/access_inet.c'\" \(3098 characters\)
  975. sed "s/^X//" >'./server/access_inet.c' <<'END_OF_FILE'
  976. X#ifndef lint
  977. static char    *sccsid = "@(#)access_inet.c    1.4    (Berkeley) 1/9/88";
  978. X#endif
  979. X
  980. X#include "common.h"
  981. X
  982. X#include <stdio.h>
  983. X#include <sys/socket.h>
  984. X#include <netinet/in.h>
  985. X#ifndef EXCELAN
  986. X#include <netdb.h>
  987. X#include <arpa/inet.h>
  988. X#endif
  989. X
  990. X/*
  991. X * inet_netnames -- return the network, subnet, and host names of
  992. X * our peer process for the Internet domain.
  993. X *
  994. X *    Parameters:    "sock" is our socket, which we don't need.
  995. X *            "sin" is a pointer to the result of
  996. X *            a getpeername() call.
  997. X *            "net_name", "subnet_name", and "host_name"
  998. X *            are filled in by this routine with the
  999. X *            corresponding ASCII names of our peer.
  1000. X *    Returns:    Nothing.
  1001. X *    Side effects:    None.
  1002. X */
  1003. X
  1004. inet_netnames(sock, sin, net_name, subnet_name, host_name)
  1005. X    int            sock;
  1006. X    struct sockaddr_in    *sin;
  1007. X    char            *net_name;
  1008. X    char            *subnet_name;
  1009. X    char            *host_name;
  1010. X{
  1011. X#ifdef EXCELAN
  1012. X    excelan_netnames(sock, sin, net_name, subnet_name, host_name);
  1013. X#else
  1014. X    static int        gotsubnetconf;
  1015. X    u_long            net_addr;
  1016. X    u_long            subnet_addr;
  1017. X    struct hostent        *hp;
  1018. X    struct netent        *np;
  1019. X
  1020. X#ifdef SUBNET
  1021. X    if (!gotsubnetconf) {
  1022. X        if (getifconf() < 0) {
  1023. X#ifdef SYSLOG
  1024. X            syslog(LOG_ERR, "host_access: getifconf: %m");
  1025. X#endif
  1026. X            return;
  1027. X        }
  1028. X        gotsubnetconf = 1;
  1029. X    }
  1030. X#endif
  1031. X
  1032. X    net_addr = inet_netof(sin->sin_addr);    /* net_addr in host order */
  1033. X    np = getnetbyaddr(net_addr, AF_INET);
  1034. X    if (np != NULL)
  1035. X        (void) strcpy(net_name, np->n_name);
  1036. X    else
  1037. X        (void) strcpy(net_name,inet_ntoa(*(struct in_addr *)&net_addr));
  1038. X
  1039. X#ifdef SUBNET
  1040. X    subnet_addr = inet_snetof(sin->sin_addr.s_addr);
  1041. X    if (subnet_addr == 0)
  1042. X        subnet_name[0] = '\0';
  1043. X    else {
  1044. X        np = getnetbyaddr(subnet_addr, AF_INET);
  1045. X        if (np != NULL)
  1046. X            (void) strcpy(subnet_name, np->n_name);
  1047. X        else
  1048. X            (void) strcpy(subnet_name,
  1049. X                inet_ntoa(*(struct in_addr *)&subnet_addr));
  1050. X    }
  1051. X#else
  1052. X    subnet_name[0] = '\0';
  1053. X#endif SUBNET
  1054. X
  1055. X    hp = gethostbyaddr((char *) &sin->sin_addr.s_addr,
  1056. X        sizeof (sin->sin_addr.s_addr), AF_INET);
  1057. X    if (hp != NULL)
  1058. X        (void) strcpy(host_name, hp->h_name);
  1059. X    else
  1060. X        (void) strcpy(host_name, inet_ntoa(sin->sin_addr));
  1061. X#endif
  1062. X}
  1063. X
  1064. X
  1065. X#ifdef EXCELAN
  1066. excelan_netnames(sock, sin, net_name, subnet_name, host_name)
  1067. X    int            sock;
  1068. X    struct sockaddr_in    *sin;
  1069. X    char            *net_name;
  1070. X    char            *subnet_name;
  1071. X    char            *host_name;
  1072. X{
  1073. X    char *hp, *raddr();
  1074. X    int octet[4];
  1075. X
  1076. X    /* assumes sizeof addr is long */
  1077. X    octet[0] = (sin->sin_addr.s_addr>>24)&0xff;
  1078. X    octet[1] = (sin->sin_addr.s_addr>>16)&0xff;
  1079. X    octet[2] = (sin->sin_addr.s_addr>>8 )&0xff;
  1080. X    octet[3] = (sin->sin_addr.s_addr    )&0xff;
  1081. X
  1082. X    hp = raddr(sin->sin_addr.s_addr);
  1083. X    if (hp != NULL)
  1084. X        (void) strcpy(host_name,hp);
  1085. X    else
  1086. X
  1087. X        (void) sprintf(host_name,"%d.%d.%d.%d",
  1088. X            octet[0],octet[1],octet[2],octet[3]);    
  1089. X    /* No inet* routines here, so we fake it. */
  1090. X    if (octet[0] < 128)        /* CLASS A address */
  1091. X        (void) sprintf(net_name,"%d",octet[0]);
  1092. X    else if(octet[0] < 192)        /* CLASS B address */
  1093. X            (void) sprintf(net_name,"%d.%d",
  1094. X                        octet[0],octet[1]);
  1095. X        else             /* CLASS C address */
  1096. X            (void) sprintf(net_name,"%d.%d.%d",
  1097. X                    octet[0],octet[1],octet[2]);
  1098. X
  1099. X/* hack to cover the subnet stuff */
  1100. X    (void) sprintf(subnet_name,"%d.%d.%d",octet[0],octet[1],octet[2]);
  1101. X}
  1102. X#endif
  1103. END_OF_FILE
  1104. if test 3098 -ne `wc -c <'./server/access_inet.c'`; then
  1105.     echo shar: \"'./server/access_inet.c'\" unpacked with wrong size!
  1106. fi
  1107. # end of './server/access_inet.c'
  1108. fi
  1109. if test -f './server/active.c' -a "${1}" != "-c" ; then 
  1110.   echo shar: Will not clobber existing file \"'./server/active.c'\"
  1111. else
  1112. echo shar: Extracting \"'./server/active.c'\" \(3476 characters\)
  1113. sed "s/^X//" >'./server/active.c' <<'END_OF_FILE'
  1114. X#ifndef lint
  1115. static char    *sccsid = "@(#)active.c    1.12    (Berkeley) 1/11/88";
  1116. X#endif
  1117. X
  1118. X#include "common.h"
  1119. X
  1120. X/*
  1121. X * Routines to deal with the active file
  1122. X */
  1123. X
  1124. int    act_cmp();
  1125. X
  1126. X/*
  1127. X * read_groups -- read the active file into memory, sort it,
  1128. X *    and return the number of newsgroups read in.
  1129. X *    If FASTFORK is true, this can be called by interrupt,
  1130. X *    and may have to free up the old storage.  We decide
  1131. X *    this by the fact that "num_groups" will be non-zero if
  1132. X *    we're here on an interrupt.
  1133. X *
  1134. X *    Parameters:    None.
  1135. X *
  1136. X *    Returns:    Number of newsgroups read into
  1137. X *            memory.
  1138. X *            Zero on error.
  1139. X *
  1140. X *    Side effects:    Reads newsgroups into "group_array"
  1141. X *            and sorts them.
  1142. X */
  1143. X
  1144. read_groups()
  1145. X{
  1146. X    register int    i;
  1147. X    register int    act_fd;
  1148. X    register char    *actbuf, *cp, *end;
  1149. X    char        *malloc();
  1150. X    struct stat    statbuf;
  1151. X
  1152. X    /*
  1153. X     * If we're here on an interrupt, free up all the
  1154. X     * previous groups.
  1155. X     */
  1156. X
  1157. X    if (num_groups != 0) {
  1158. X        (void) free(group_array[0]);    /* Assume [0] -> actbuf */
  1159. X        (void) free(group_array);
  1160. X    }
  1161. X
  1162. X    act_fd = open(activefile, O_RDONLY);
  1163. X    if (act_fd < 0) {
  1164. X#ifdef SYSLOG
  1165. X        syslog(LOG_ERR, "read_groups: open %s: %m", activefile);
  1166. X#endif
  1167. X        return (0);
  1168. X    }
  1169. X
  1170. X    if (fstat(act_fd, &statbuf) < 0) {
  1171. X#ifdef SYSLOG
  1172. X        syslog(LOG_ERR, "read_groups: fstat: %m");
  1173. X#endif
  1174. X        (void) close(act_fd);
  1175. X        return (0);
  1176. X    }
  1177. X
  1178. X    actbuf = malloc(statbuf.st_size);
  1179. X    if (actbuf == NULL) {
  1180. X#ifdef SYSLOG
  1181. X        syslog(LOG_ERR, "read_groups: malloc %d bytes: %m",
  1182. X            statbuf.st_size);
  1183. X#endif
  1184. X        (void) close(act_fd);
  1185. X        return (0);
  1186. X    }
  1187. X
  1188. X    if (read(act_fd, actbuf, (int)statbuf.st_size) != statbuf.st_size) {
  1189. X#ifdef SYSLOG
  1190. X        syslog(LOG_ERR, "read_groups: read %d bytes: %m",
  1191. X            statbuf.st_size);
  1192. X#endif
  1193. X        (void) close(act_fd);
  1194. X        return (0);
  1195. X    }
  1196. X
  1197. X    (void) close(act_fd);
  1198. X
  1199. X    for (i = 0, cp = actbuf, end = actbuf + statbuf.st_size; cp < end; cp++)
  1200. X        if (*cp == '\n')
  1201. X            i++;
  1202. X
  1203. X    group_array = (char **) malloc(i * (sizeof (char *)));
  1204. X    if (group_array == NULL) {
  1205. X#ifdef SYSLOG
  1206. X        syslog(LOG_ERR, "read_groups: malloc %d bytes: %m",
  1207. X            i * sizeof (char **));
  1208. X#endif
  1209. X        (void) close(act_fd);
  1210. X        return (0);
  1211. X    }
  1212. X
  1213. X    cp = actbuf;
  1214. X    i = 0;
  1215. X    while (cp < end) {
  1216. X        group_array[i++] = cp;
  1217. X        cp = index(cp, '\n');
  1218. X        if (cp == NULL)
  1219. X            break;
  1220. X        *cp = '\0';
  1221. X        cp++;
  1222. X    }
  1223. X
  1224. X    qsort((char *) group_array, i, sizeof (char *), act_cmp);
  1225. X
  1226. X    return (i);
  1227. X}
  1228. X
  1229. X
  1230. act_cmp(ptr1, ptr2)
  1231. X    char     **ptr1, **ptr2;
  1232. X{
  1233. X    return(strcmp(*ptr1, *ptr2));
  1234. X}
  1235. X
  1236. X
  1237. X/*
  1238. X * find_group -- find a given newsgroup and return
  1239. X *    the low and high message numbers in the group
  1240. X *    (space provided by user).
  1241. X *
  1242. X *    Parameters:    "group" is the name of the group
  1243. X *            we're searching for.
  1244. X *            "num_groups" is the total number
  1245. X *            of groups in the group array.
  1246. X *            "low_msg" and "high_msg" are
  1247. X *            pointers to where we're supposed
  1248. X *            to put the low and high message numbers.
  1249. X *
  1250. X *    Returns:    0 if all goes well,
  1251. X *            -1 if we can't find the group.
  1252. X *
  1253. X *    Side effects:    None.
  1254. X */
  1255. X
  1256. find_group(group, num_groups, low_msg, high_msg)
  1257. X    char        *group;
  1258. X    int        num_groups;
  1259. X    int        *low_msg, *high_msg;
  1260. X{
  1261. X    char        kludgebuf[MAXBUFLEN];
  1262. X    int        cond;
  1263. X    register int    low, high, mid;
  1264. X    int        length;
  1265. X
  1266. X    low = 0;
  1267. X    high = num_groups-1;
  1268. X    (void) strcpy(kludgebuf, group);
  1269. X    (void) strcat(kludgebuf, " ");
  1270. X    length = strlen(kludgebuf);
  1271. X
  1272. X    while (low <= high) {
  1273. X        mid = (low + high) / 2;
  1274. X        if ((cond = strncmp(kludgebuf, group_array[mid], length)) < 0)
  1275. X            high = mid - 1;
  1276. X        else if (cond > 0)
  1277. X            low = mid + 1;
  1278. X        else {
  1279. X            (void) sscanf(group_array[mid], "%s %d %d",
  1280. X                kludgebuf, high_msg, low_msg);
  1281. X            return(0);
  1282. X        }
  1283. X    }
  1284. X    return(-1);
  1285. X}
  1286. END_OF_FILE
  1287. if test 3476 -ne `wc -c <'./server/active.c'`; then
  1288.     echo shar: \"'./server/active.c'\" unpacked with wrong size!
  1289. fi
  1290. # end of './server/active.c'
  1291. fi
  1292. if test -f './server/strcasecmp.c' -a "${1}" != "-c" ; then 
  1293.   echo shar: Will not clobber existing file \"'./server/strcasecmp.c'\"
  1294. else
  1295. echo shar: Extracting \"'./server/strcasecmp.c'\" \(3456 characters\)
  1296. sed "s/^X//" >'./server/strcasecmp.c' <<'END_OF_FILE'
  1297. X/*
  1298. X * Copyright (c) 1987 Regents of the University of California.
  1299. X * All rights reserved.
  1300. X *
  1301. X * Redistribution and use in source and binary forms are permitted
  1302. X * provided that this notice is preserved and that due credit is given
  1303. X * to the University of California at Berkeley. The name of the University
  1304. X * may not be used to endorse or promote products derived from this
  1305. X * software without specific written prior permission. This software
  1306. X * is provided ``as is'' without express or implied warranty.
  1307. X */
  1308. X
  1309. X#if defined(LIBC_SCCS) && !defined(lint)
  1310. static char sccsid[] = "@(#)strcasecmp.c    5.5 (Berkeley) 11/24/87";
  1311. X#endif /* LIBC_SCCS and not lint */
  1312. X
  1313. X#include <sys/types.h>
  1314. X
  1315. X/*
  1316. X * This array is designed for mapping upper and lower case letter
  1317. X * together for a case independent comparison.  The mappings are
  1318. X * based upon ascii character sequences.
  1319. X */
  1320. static u_char charmap[] = {
  1321. X    '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
  1322. X    '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
  1323. X    '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
  1324. X    '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
  1325. X    '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
  1326. X    '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
  1327. X    '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
  1328. X    '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
  1329. X    '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
  1330. X    '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
  1331. X    '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
  1332. X    '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
  1333. X    '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
  1334. X    '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
  1335. X    '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
  1336. X    '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
  1337. X    '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
  1338. X    '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
  1339. X    '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
  1340. X    '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
  1341. X    '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
  1342. X    '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
  1343. X    '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
  1344. X    '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
  1345. X    '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
  1346. X    '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
  1347. X    '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
  1348. X    '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
  1349. X    '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
  1350. X    '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
  1351. X    '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
  1352. X    '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
  1353. X};
  1354. X
  1355. strcasecmp(s1, s2)
  1356. X    char *s1, *s2;
  1357. X{
  1358. X    register u_char    *cm = charmap,
  1359. X            *us1 = (u_char *)s1,
  1360. X            *us2 = (u_char *)s2;
  1361. X
  1362. X    while (cm[*us1] == cm[*us2++])
  1363. X        if (*us1++ == '\0')
  1364. X            return(0);
  1365. X    return(cm[*us1] - cm[*--us2]);
  1366. X}
  1367. X
  1368. strncasecmp(s1, s2, n)
  1369. X    char *s1, *s2;
  1370. X    register int n;
  1371. X{
  1372. X    register u_char    *cm = charmap,
  1373. X            *us1 = (u_char *)s1,
  1374. X            *us2 = (u_char *)s2;
  1375. X
  1376. X    while (--n >= 0 && cm[*us1] == cm[*us2++])
  1377. X        if (*us1++ == '\0')
  1378. X            return(0);
  1379. X    return(n < 0 ? 0 : cm[*us1] - cm[*--us2]);
  1380. X}
  1381. END_OF_FILE
  1382. if test 3456 -ne `wc -c <'./server/strcasecmp.c'`; then
  1383.     echo shar: \"'./server/strcasecmp.c'\" unpacked with wrong size!
  1384. fi
  1385. # end of './server/strcasecmp.c'
  1386. fi
  1387. if test -f './server/time.c' -a "${1}" != "-c" ; then 
  1388.   echo shar: Will not clobber existing file \"'./server/time.c'\"
  1389. else
  1390. echo shar: Extracting \"'./server/time.c'\" \(4156 characters\)
  1391. sed "s/^X//" >'./server/time.c' <<'END_OF_FILE'
  1392. X#ifndef lint
  1393. static char    *sccsid = "@(#)time.c    1.9    (Berkeley) 2/6/88";
  1394. X#endif
  1395. X
  1396. X/*
  1397. X * Collection of routines for dealing with ASCII time strings.
  1398. X * These may actually be useful in their own right.
  1399. X */
  1400. X
  1401. X#include "../common/conf.h"
  1402. X
  1403. X#include <stdio.h>
  1404. X#include <sys/types.h>
  1405. X#include <ctype.h>
  1406. X#ifdef USG
  1407. X#include <time.h>
  1408. X#else not USG
  1409. X#include <strings.h>
  1410. X#include <sys/time.h>
  1411. X#endif not USG
  1412. X
  1413. X/*
  1414. X * dtol -- convert date to long integer.  This is not implicitly
  1415. X * local time, or any other kind of time, for that matter.  If you
  1416. X * pass it a date you think is GMT, you wind up with that number of
  1417. X * seconds...
  1418. X *
  1419. X *    Parameters:        "date_ascii" is in the form "yymmddhhmmss".
  1420. X *
  1421. X *    Returns:        Long integer containing number
  1422. X *                of seconds since 000000 Jan 1, 1970,
  1423. X *                and "date".  -1 on error.
  1424. X *
  1425. X *    Side effects:        None.
  1426. X */
  1427. X
  1428. X#define twodigtoi(x)    (((x[0]) - '0') + (x[1] - '0')*10)
  1429. X#define    dysize(y)    ((y % 4 ? 365 : 366))
  1430. X
  1431. static    int    dmsize[12] =
  1432. X    { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  1433. X
  1434. long
  1435. dtol(date_ascii)
  1436. X    char    *date_ascii;
  1437. X{
  1438. X    char    date[32], *date_str;
  1439. X    char    *lhs, *rhs;
  1440. X    char    temp;
  1441. X    long    seconds;
  1442. X    int    year, month, day, hour, mins, secs;
  1443. X    int    len, i;
  1444. X
  1445. X    len = strlen(date_ascii);
  1446. X    if (len != sizeof("yymmddhhmmss")-1)
  1447. X        return (-1);
  1448. X
  1449. X    (void) strcpy(date, date_ascii);
  1450. X    date_str = date;
  1451. X
  1452. X#ifdef debug
  1453. X    printf("date_str = %s\n", date_str);
  1454. X#endif
  1455. X    rhs = date_str + len - 1;
  1456. X    lhs = date_str;
  1457. X
  1458. X    for (; lhs < rhs; ++lhs, --rhs) {
  1459. X        temp = *lhs;
  1460. X        *lhs = *rhs;
  1461. X        *rhs = temp;
  1462. X        if (!isdigit(temp) || !isdigit(*lhs))
  1463. X            return (-1);
  1464. X    }
  1465. X
  1466. X    lhs = date_str;
  1467. X#ifdef debug
  1468. X    printf("date_str = %s\n", date_str);
  1469. X#endif
  1470. X
  1471. X    secs = twodigtoi(lhs);
  1472. X    lhs += 2;
  1473. X    mins = twodigtoi(lhs);
  1474. X    lhs += 2;
  1475. X    hour = twodigtoi(lhs);
  1476. X    lhs += 2;
  1477. X    day = twodigtoi(lhs);
  1478. X    lhs += 2;
  1479. X    month = twodigtoi(lhs);
  1480. X    lhs += 2;
  1481. X    year = twodigtoi(lhs);
  1482. X
  1483. X    if (month < 1 || month > 12 ||
  1484. X        day < 1 || day > 31 ||
  1485. X        mins < 0 || mins > 59 ||
  1486. X        secs < 0 || secs > 59)
  1487. X        return (-1);
  1488. X    if (hour == 24) {
  1489. X        hour = 0;
  1490. X        day++;
  1491. X    }
  1492. X    if (hour < 0 || hour > 23)
  1493. X        return (-1);
  1494. X    seconds = 0;
  1495. X    year += 1900;
  1496. X    for (i = 1970; i < year; i++)
  1497. X        seconds += dysize(i);
  1498. X    /* Leap year */
  1499. X    if (dysize(year) == 366 && month >= 3)
  1500. X        seconds++;
  1501. X    while (--month)
  1502. X        seconds += dmsize[month-1];
  1503. X    seconds += day-1;
  1504. X    seconds = 24 * seconds + hour;
  1505. X    seconds = 60 * seconds + mins;
  1506. X    seconds = 60 * seconds + secs;
  1507. X
  1508. X    return (seconds);
  1509. X}
  1510. X
  1511. X
  1512. X/*
  1513. X * ltod -- convert long integer to date string.
  1514. X *
  1515. X *    Parameters:        "date" is in the number of seconds
  1516. X *                since the epoch.
  1517. X *
  1518. X *    Returns:        Pointer to static data in the form
  1519. X *                yymmddhhmmss\0.
  1520. X *
  1521. X *    Side effects:        None.
  1522. X */
  1523. X
  1524. char *
  1525. ltod(date)
  1526. X    long        date;
  1527. X{
  1528. X    static char    timebuf[32];
  1529. X    struct tm    *tp;
  1530. X
  1531. X    tp = gmtime(&date);
  1532. X
  1533. X    (void) sprintf(timebuf, "%02d%02d%02d%02d%02d%02d",
  1534. X        tp->tm_year,
  1535. X        tp->tm_mon + 1,        /* 0 to 11??? How silly. */
  1536. X        tp->tm_mday,
  1537. X        tp->tm_hour,
  1538. X        tp->tm_min,
  1539. X        tp->tm_sec);
  1540. X
  1541. X    return (timebuf);
  1542. X}
  1543. X
  1544. X
  1545. X/*
  1546. X * local_to_gmt -- convert a local time (in form of number of
  1547. X * seconds since you-know-when) to GMT.
  1548. X *
  1549. X *    Parameters:    "date" is date we want converted, in
  1550. X *            seconds since 000000 1 Jan 1970.
  1551. X *
  1552. X *    Returns:    Number of seconds corrected for local
  1553. X *            and dst.
  1554. X */
  1555. X
  1556. long
  1557. local_to_gmt(date)
  1558. X    long    date;
  1559. X{
  1560. X#ifdef USG
  1561. X    extern    int    timezone;
  1562. X    tzset();
  1563. X    date += timezone;
  1564. X#else not USG
  1565. X    struct    timeval    tv;
  1566. X    struct    timezone tz;
  1567. X
  1568. X    (void) gettimeofday(&tv, &tz);
  1569. X    date += (long) tz.tz_minuteswest * 60;
  1570. X#endif not USG
  1571. X
  1572. X    /* now fix up local daylight time */
  1573. X    if (localtime((time_t *)&date)->tm_isdst)
  1574. X        date -= 60*60;
  1575. X
  1576. X    return (date);
  1577. X}
  1578. X
  1579. X/*
  1580. X * gmt_to_local -- take a GMT time expressed in seconds since
  1581. X * the epoch, and convert it to local time.
  1582. X *
  1583. X *    Parameters:    "date" is the number of seconds...
  1584. X *
  1585. X *    Returns:    Number of seconds corrected to reflect
  1586. X *            local time and dst.
  1587. X */
  1588. X
  1589. long
  1590. gmt_to_local(date)
  1591. X    long    date;
  1592. X{
  1593. X#ifdef USG
  1594. X    extern    int    timezone;
  1595. X    tzset();
  1596. X    date -= timezone;
  1597. X#else not USG
  1598. X    struct    timeval    tv;
  1599. X    struct    timezone tz;
  1600. X
  1601. X    (void) gettimeofday(&tv, &tz);
  1602. X    date -= (long) tz.tz_minuteswest * 60;
  1603. X#endif not USG
  1604. X
  1605. X    /* now fix up local daylight time */
  1606. X    if (localtime((time_t *)&date)->tm_isdst)
  1607. X        date += 60*60;
  1608. X
  1609. X    return (date);
  1610. X}
  1611. END_OF_FILE
  1612. if test 4156 -ne `wc -c <'./server/time.c'`; then
  1613.     echo shar: \"'./server/time.c'\" unpacked with wrong size!
  1614. fi
  1615. # end of './server/time.c'
  1616. fi
  1617. if test -f './server/xhdr.c' -a "${1}" != "-c" ; then 
  1618.   echo shar: Will not clobber existing file \"'./server/xhdr.c'\"
  1619. else
  1620. echo shar: Extracting \"'./server/xhdr.c'\" \(3457 characters\)
  1621. sed "s/^X//" >'./server/xhdr.c' <<'END_OF_FILE'
  1622. X#ifndef lint
  1623. static char    *sccsid = "@(#)xhdr.c    1.6    (Berkeley) 2/25/88";
  1624. X#endif
  1625. X
  1626. X#include "common.h"
  1627. X
  1628. X#ifdef XHDR
  1629. X
  1630. X/*
  1631. X * XHDR header [<messageid>|articlerange]
  1632. X *
  1633. X * header is a case-insensitive header field, minus any colons.
  1634. X *
  1635. X * articlerange is one of:
  1636. X *    an article number
  1637. X *    an article number followed by a dash to indicate all following
  1638. X *    an article number followed by a dash followed by another
  1639. X *        article number.
  1640. X * e.g.,
  1641. X * XHDR subject            retrieve subject of current article
  1642. X * XHDR subject 5589-6325    retrieve subject of arts 5589 to 6325
  1643. X * XHDR subject 5589-        retrieve subject of arts 5589 and up
  1644. X * XHDR subject 5589        retrieve subject of art 5589 only
  1645. X * XHDR subject <123@ucbvax>    retrieve subject of art <123@ucbvax>
  1646. X *
  1647. X * This command is an extention, and not included in RFC 977.
  1648. X */
  1649. X
  1650. xhdr(argc, argv)
  1651. X    int        argc;
  1652. X    char        *argv[];
  1653. X{
  1654. X    char        buf[MAXPATHLEN];
  1655. X    register int    artptr;
  1656. X    register int    artnum;
  1657. X    register int    low, high;
  1658. X    register FILE    *fp;
  1659. X    register char    *cp;
  1660. X
  1661. X    if (argc < 2 || argc > 3) {
  1662. X        printf("%d Usage: XHDR headerfield [artrange|<message-id>]\r\n",
  1663. X            ERR_CMDSYN);
  1664. X        (void) fflush(stdout);
  1665. X        return;
  1666. X    }
  1667. X
  1668. X    if (!canread) {
  1669. X        printf("%d You only have permission to transfer, sorry.\r\n",
  1670. X            ERR_ACCESS);
  1671. X        (void) fflush(stdout);
  1672. X        return;
  1673. X    }
  1674. X
  1675. X    /* Handle message-id requests */
  1676. X
  1677. X    if (argc == 3 && *argv[2] == '<') {    /* Message ID */
  1678. X        fp = openartbyid(argv[2]);
  1679. X        if (fp == NULL) {
  1680. X            printf("%d No article by message-id %s, sorry.\r\n",
  1681. X                ERR_NOART, argv[2]);
  1682. X            (void) fflush(stdout);
  1683. X            return;
  1684. X        }
  1685. X        printf("%d 0 %s header of article %s.\r\n",
  1686. X            OK_HEAD, argv[1], argv[2]);
  1687. X        print_header(fp, argv[1], argv[2]);
  1688. X        (void) fclose(fp);
  1689. X
  1690. X        putchar('.');
  1691. X        putchar('\r');
  1692. X        putchar('\n');
  1693. X        (void) fflush(stdout);
  1694. X        return;
  1695. X    }
  1696. X
  1697. X    /*
  1698. X     * It must be a range of articles, which means that we need
  1699. X     * to be in a newsgroup already.
  1700. X     */
  1701. X
  1702. X    if (!ingroup) {
  1703. X        printf("%d You are not currently in a newsgroup.\r\n",
  1704. X            ERR_NCING);
  1705. X        (void) fflush(stdout);
  1706. X        return;
  1707. X    }
  1708. X
  1709. X    artptr = 0;
  1710. X
  1711. X    if (argc == 2) {
  1712. X        if (art_ptr < 0 || art_ptr >= num_arts) {
  1713. X            printf("%d No article is currently selected.\r\n",
  1714. X                ERR_NOCRNT);
  1715. X            (void) fflush(stdout);
  1716. X            return;
  1717. X        }
  1718. X        high = low = art_array[art_ptr];
  1719. X        artptr = art_ptr;
  1720. X    } else {
  1721. X        cp = index(argv[2], '-');
  1722. X        if (cp == NULL)
  1723. X            low = high = atoi(argv[2]);
  1724. X        else {
  1725. X            *cp = '\0';
  1726. X            low = atoi(argv[2]);
  1727. X            cp++;
  1728. X            high = atoi(cp);
  1729. X            if (high < low)
  1730. X                high = art_array[num_arts-1];
  1731. X        }
  1732. X    }
  1733. X
  1734. X    printf("%d %s fields follow\r\n", OK_HEAD, argv[1]);
  1735. X
  1736. X    for (;; artptr++) {
  1737. X        if ((artnum = art_array[artptr]) < low)
  1738. X            continue;
  1739. X        if (artnum > high)
  1740. X            break;
  1741. X
  1742. X        (void) sprintf(buf, "%d", artnum);
  1743. X        fp = fopen(buf, "r");
  1744. X        if (fp == NULL)
  1745. X            continue;
  1746. X        print_header(fp, argv[1], buf);
  1747. X        (void) fclose(fp);
  1748. X    }
  1749. X
  1750. X    putchar('.');
  1751. X    putchar('\r');
  1752. X    putchar('\n');
  1753. X    (void) fflush(stdout);
  1754. X}
  1755. X
  1756. X
  1757. print_header(fp, header, artname)
  1758. X    register FILE    *fp;
  1759. X    register char    *header;
  1760. X    register char    *artname;
  1761. X{
  1762. X    char        line[NNTP_STRLEN];
  1763. X    register char    *cp, *cp1;
  1764. X
  1765. X    while (fgets(line, sizeof (line), fp) != NULL) {
  1766. X        if (*line == '\n' || *line == '\0') {
  1767. X            printf("%s (none)\r\n", artname);
  1768. X            return;
  1769. X        }
  1770. X        if (cp = index(line, ':')) {
  1771. X            *cp = '\0';
  1772. X            if (!strcasecmp(header, line)) {
  1773. X                if (cp1 = index(cp + 2, '\n'))
  1774. X                    *cp1 = '\0';
  1775. X                printf("%s %s\r\n", artname, cp + 2);
  1776. X                return;
  1777. X            }
  1778. X        }
  1779. X    }
  1780. X}
  1781. X
  1782. X#else not XHDR
  1783. X
  1784. X/* Kludge to get around Greenhills C compiler */
  1785. X
  1786. xhdr_greenkluydge()
  1787. X{
  1788. X}
  1789. X
  1790. X#endif not XHDR
  1791. END_OF_FILE
  1792. if test 3457 -ne `wc -c <'./server/xhdr.c'`; then
  1793.     echo shar: \"'./server/xhdr.c'\" unpacked with wrong size!
  1794. fi
  1795. # end of './server/xhdr.c'
  1796. fi
  1797. if test -f './support/mkgrdates.c' -a "${1}" != "-c" ; then 
  1798.   echo shar: Will not clobber existing file \"'./support/mkgrdates.c'\"
  1799. else
  1800. echo shar: Extracting \"'./support/mkgrdates.c'\" \(3755 characters\)
  1801. sed "s/^X//" >'./support/mkgrdates.c' <<'END_OF_FILE'
  1802. X#ifndef lint
  1803. static char    *sccsid = "@(#)mkgrdates.c    1.4    (Berkeley) 2/6/88";
  1804. X#endif
  1805. X
  1806. X/*
  1807. X * Make a list of newsgroups which are "new" in the file NGDATE_FILE.
  1808. X * "New" means having an entry in the active file, and having
  1809. X * a message numbered "1" in the appropriate news directory.
  1810. X * Since this involves a stat of all the newsgroups, we try
  1811. X * to be intelligent about things -- if the active file's size
  1812. X * since we last ran -- stored in STAT_FILE -- hasn't changed
  1813. X * since last time, we assume things are ok, and exit without
  1814. X * doing anything.  This could fail in extreme circumstances,
  1815. X * but is "too painful to do right".
  1816. X *
  1817. X * Output in NGDATE_FILE is of the form
  1818. X *
  1819. X *    date newsgroup
  1820. X *
  1821. X * where "date" is the date the newsgroup was created, expressed as
  1822. X * the number of seconds since 000000 Jan 1, 1970, GMT.  This file
  1823. X * winds up sorted in cronological order.
  1824. X *
  1825. X *    Phil Lapsley
  1826. X *    College of Engineering
  1827. X *    University of California, Berkeley
  1828. X *    (ARPA: phil@Berkeley.ARPA; UUCP: ...!ucbvax!phil)
  1829. X */
  1830. X
  1831. X#include <stdio.h>
  1832. X#include <sys/types.h>
  1833. X#include <sys/stat.h>
  1834. X#include "../common/conf.h"
  1835. X#ifdef USG
  1836. X#include <time.h>
  1837. X#else not USG
  1838. X#include <sys/time.h>
  1839. X#endif not USG
  1840. X
  1841. X#define MODE        0644    /* Better be readable by nntpd! */
  1842. X
  1843. X#ifndef MAXPATHLEN
  1844. X#define    MAXPATHLEN    1024
  1845. X#endif
  1846. X
  1847. X#ifndef MAXGROUPLEN
  1848. X#define    MAXGROUPLEN    256
  1849. X#endif
  1850. X
  1851. extern    int    linecmp();
  1852. extern    char    *index(), *malloc(), *strcpy(), *strcat();
  1853. X
  1854. main(argc, argv)
  1855. int    argc;
  1856. char    *argv[];
  1857. X{
  1858. X    char    *groups[1024];        /* XXX 1024 groups max */
  1859. X    char    line[MAXPATHLEN], gr_name[MAXGROUPLEN];
  1860. X    char    *cp;
  1861. X    int    i, j;
  1862. X    long    lastsize, crntsize;
  1863. X    long    birthtime;
  1864. X    struct tm *tmptr;
  1865. X    FILE    *stat_fp, *active_fp, *date_fp;
  1866. X    long    birthof();
  1867. X
  1868. X    stat_fp = fopen(STAT_FILE, "r");
  1869. X
  1870. X    if (stat_fp != NULL) {
  1871. X        (void) fscanf(stat_fp, "%d", &lastsize);
  1872. X        (void) fclose(stat_fp);
  1873. X    }
  1874. X
  1875. X    active_fp = fopen(ACTIVE_FILE, "r");
  1876. X    if (active_fp == NULL) {
  1877. X        fprintf(stderr, "Can't read active file?\n");
  1878. X        perror(ACTIVE_FILE);
  1879. X        exit(1);
  1880. X    }
  1881. X
  1882. X    /* Check length; if it's the same as last time, quit */
  1883. X
  1884. X    (void) fseek(active_fp, (long) 0, 2);
  1885. X    crntsize = ftell(active_fp);
  1886. X    if (crntsize == lastsize) {
  1887. X        (void) fclose(active_fp);
  1888. X        exit(0);
  1889. X    }
  1890. X
  1891. X    /* Ok, time to rebuild the date file */
  1892. X
  1893. X    date_fp = fopen(NGDATE_FILE, "w");
  1894. X
  1895. X    if (date_fp == NULL) {
  1896. X        perror(NGDATE_FILE);
  1897. X        (void) fclose(active_fp);
  1898. X        exit(1);
  1899. X    }
  1900. X
  1901. X    rewind(active_fp);
  1902. X
  1903. X    i = 0;
  1904. X    while (fgets(line, sizeof(line), active_fp) != NULL) {
  1905. X        if ((cp = index(line, ' ')) != NULL)
  1906. X            *cp = '\0';
  1907. X        (void) strcpy(gr_name, line);
  1908. X        birthtime = birthof(line, atoi(cp + 1));
  1909. X        
  1910. X        if (birthtime == 0)    /* Skip ancient newsgroups */
  1911. X            continue;
  1912. X
  1913. X        (void) sprintf(line, "%ld %s", birthtime, gr_name);
  1914. X        groups[i] = malloc(strlen(line)+1);
  1915. X        if (groups[i] != NULL)
  1916. X            (void) strcpy(groups[i++], line);
  1917. X        else {
  1918. X            perror("malloc");
  1919. X            exit(1);
  1920. X        }
  1921. X    }
  1922. X
  1923. X    (void) fclose(active_fp);
  1924. X
  1925. X    qsort((char *) groups, i, sizeof(char *), linecmp);
  1926. X
  1927. X    for (j = 0; j < i; ++j)
  1928. X        fprintf(date_fp, "%s\n", groups[j]);
  1929. X
  1930. X    (void) fclose(date_fp);
  1931. X
  1932. X    (void) chmod(NGDATE_FILE, MODE);
  1933. X
  1934. X    stat_fp = fopen(STAT_FILE, "w");
  1935. X    if (stat_fp == NULL) {
  1936. X        perror(STAT_FILE);
  1937. X        exit(1);
  1938. X    }
  1939. X
  1940. X    fprintf(stat_fp, "%d\n", crntsize);
  1941. X
  1942. X    (void) fclose(stat_fp);
  1943. X
  1944. X    (void) chmod(STAT_FILE, MODE);
  1945. X
  1946. X    exit(0);
  1947. X}
  1948. X
  1949. linecmp(line1, line2)
  1950. char     **line1, **line2;
  1951. X{
  1952. X    return(0 - strcmp(*line1, *line2));
  1953. X}
  1954. X
  1955. X
  1956. X/* return creation time of newsgroup */
  1957. X
  1958. long
  1959. birthof(group, highart)
  1960. char    *group;
  1961. int    highart;
  1962. X{
  1963. X    char    *cp, *index();
  1964. X    char    tst[128];
  1965. X    struct stat statbuf;
  1966. X    while ((cp = index(group, '.')))
  1967. X        *cp = '/';
  1968. X
  1969. X    (void) strcpy(tst, SPOOLDIR);
  1970. X    (void) strcat(tst, group);
  1971. X    if (highart)
  1972. X        (void) strcat(tst, "/1");
  1973. X    if (stat(tst, &statbuf) < 0)
  1974. X        return 0L;        /* not there, assume ancient */
  1975. X    else
  1976. X        return(statbuf.st_mtime);
  1977. X}
  1978. END_OF_FILE
  1979. if test 3755 -ne `wc -c <'./support/mkgrdates.c'`; then
  1980.     echo shar: \"'./support/mkgrdates.c'\" unpacked with wrong size!
  1981. fi
  1982. # end of './support/mkgrdates.c'
  1983. fi
  1984. if test -f './xmit/sysexits.h' -a "${1}" != "-c" ; then 
  1985.   echo shar: Will not clobber existing file \"'./xmit/sysexits.h'\"
  1986. else
  1987. echo shar: Extracting \"'./xmit/sysexits.h'\" \(4212 characters\)
  1988. sed "s/^X//" >'./xmit/sysexits.h' <<'END_OF_FILE'
  1989. X/*
  1990. X * Copyright (c) 1987 Regents of the University of California.
  1991. X * All rights reserved.
  1992. X *
  1993. X * Redistribution and use in source and binary forms are permitted
  1994. X * provided that this notice is preserved and that due credit is given
  1995. X * to the University of California at Berkeley. The name of the University
  1996. X * may not be used to endorse or promote products derived from this
  1997. X * software without specific prior written permission. This software
  1998. X * is provided ``as is'' without express or implied warranty.
  1999. X *
  2000. X *    @(#)sysexits.h    4.3 (Berkeley) 12/15/87
  2001. X */
  2002. X
  2003. X/*
  2004. X**  SYSEXITS.H -- Exit status codes for system programs.
  2005. X**
  2006. X**    This include file attempts to categorize possible error
  2007. X**    exit statuses for system programs, notably delivermail
  2008. X**    and the Berkeley network.
  2009. X**
  2010. X**    Error numbers begin at EX__BASE to reduce the possibility of
  2011. X**    clashing with other exit statuses that random programs may
  2012. X**    already return.  The meaning of the codes is approximately
  2013. X**    as follows:
  2014. X**
  2015. X**    EX_USAGE -- The command was used incorrectly, e.g., with
  2016. X**        the wrong number of arguments, a bad flag, a bad
  2017. X**        syntax in a parameter, or whatever.
  2018. X**    EX_DATAERR -- The input data was incorrect in some way.
  2019. X**        This should only be used for user's data & not
  2020. X**        system files.
  2021. X**    EX_NOINPUT -- An input file (not a system file) did not
  2022. X**        exist or was not readable.  This could also include
  2023. X**        errors like "No message" to a mailer (if it cared
  2024. X**        to catch it).
  2025. X**    EX_NOUSER -- The user specified did not exist.  This might
  2026. X**        be used for mail addresses or remote logins.
  2027. X**    EX_NOHOST -- The host specified did not exist.  This is used
  2028. X**        in mail addresses or network requests.
  2029. X**    EX_UNAVAILABLE -- A service is unavailable.  This can occur
  2030. X**        if a support program or file does not exist.  This
  2031. X**        can also be used as a catchall message when something
  2032. X**        you wanted to do doesn't work, but you don't know
  2033. X**        why.
  2034. X**    EX_SOFTWARE -- An internal software error has been detected.
  2035. X**        This should be limited to non-operating system related
  2036. X**        errors as possible.
  2037. X**    EX_OSERR -- An operating system error has been detected.
  2038. X**        This is intended to be used for such things as "cannot
  2039. X**        fork", "cannot create pipe", or the like.  It includes
  2040. X**        things like getuid returning a user that does not
  2041. X**        exist in the passwd file.
  2042. X**    EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp,
  2043. X**        etc.) does not exist, cannot be opened, or has some
  2044. X**        sort of error (e.g., syntax error).
  2045. X**    EX_CANTCREAT -- A (user specified) output file cannot be
  2046. X**        created.
  2047. X**    EX_IOERR -- An error occurred while doing I/O on some file.
  2048. X**    EX_TEMPFAIL -- temporary failure, indicating something that
  2049. X**        is not really an error.  In sendmail, this means
  2050. X**        that a mailer (e.g.) could not create a connection,
  2051. X**        and the request should be reattempted later.
  2052. X**    EX_PROTOCOL -- the remote system returned something that
  2053. X**        was "not possible" during a protocol exchange.
  2054. X**    EX_NOPERM -- You did not have sufficient permission to
  2055. X**        perform the operation.  This is not intended for
  2056. X**        file system problems, which should use NOINPUT or
  2057. X**        CANTCREAT, but rather for higher level permissions.
  2058. X**        For example, kre uses this to restrict who students
  2059. X**        can send mail to.
  2060. X**
  2061. X**    Maintained by Eric Allman (eric@berkeley, ucbvax!eric) --
  2062. X**        please mail changes to me.
  2063. X**
  2064. X**            @(#)sysexits.h    4.3        12/15/87
  2065. X*/
  2066. X
  2067. X# define EX_OK        0    /* successful termination */
  2068. X
  2069. X# define EX__BASE    64    /* base value for error messages */
  2070. X
  2071. X# define EX_USAGE    64    /* command line usage error */
  2072. X# define EX_DATAERR    65    /* data format error */
  2073. X# define EX_NOINPUT    66    /* cannot open input */
  2074. X# define EX_NOUSER    67    /* addressee unknown */
  2075. X# define EX_NOHOST    68    /* host name unknown */
  2076. X# define EX_UNAVAILABLE    69    /* service unavailable */
  2077. X# define EX_SOFTWARE    70    /* internal software error */
  2078. X# define EX_OSERR    71    /* system error (e.g., can't fork) */
  2079. X# define EX_OSFILE    72    /* critical OS file missing */
  2080. X# define EX_CANTCREAT    73    /* can't create (user) output file */
  2081. X# define EX_IOERR    74    /* input/output error */
  2082. X# define EX_TEMPFAIL    75    /* temp failure; user is invited to retry */
  2083. X# define EX_PROTOCOL    76    /* remote error in protocol */
  2084. X# define EX_NOPERM    77    /* permission denied */
  2085. END_OF_FILE
  2086. if test 4212 -ne `wc -c <'./xmit/sysexits.h'`; then
  2087.     echo shar: \"'./xmit/sysexits.h'\" unpacked with wrong size!
  2088. fi
  2089. # end of './xmit/sysexits.h'
  2090. fi
  2091. echo shar: End of archive 3 \(of 9\).
  2092. cp /dev/null ark3isdone
  2093. MISSING=""
  2094. for I in 1 2 3 4 5 6 7 8 9 ; do
  2095.     if test ! -f ark${I}isdone ; then
  2096.     MISSING="${MISSING} ${I}"
  2097.     fi
  2098. done
  2099. if test "${MISSING}" = "" ; then
  2100.     echo You have unpacked all 9 archives.
  2101.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2102. else
  2103.     echo You still need to unpack the following archives:
  2104.     echo "        " ${MISSING}
  2105. fi
  2106. ##  End of shell archive.
  2107. exit 0
  2108.